const {Kafka, Partitioners} = require('kafkajs')

const kafka = new Kafka({
    clientId: 'my-app',
    brokers: ['kafka1:9092', 'kafka2:9092'],
})
const producer = kafka.producer({
    createPartitioner: Partitioners.DefaultPartitioner,
    allowAutoTopicCreation: false,
})

await producer.connect()
await producer.send({
    topic: 'test-topic',
    messages: [
        {key: "10000", value: 'Hello KafkaJS user!'},
    ],
})

await producer.disconnect()
